package com.qasystem.qa.system.controller;

import com.qasystem.qa.core.base.BaseController;
import com.qasystem.qa.core.base.Result;
import com.qasystem.qa.core.constants.BaseEnums;
import com.qasystem.qa.core.utils.Results;
import com.qasystem.qa.system.entity.Major;
import com.qasystem.qa.system.service.MajorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.awt.geom.RectangularShape;
import java.util.List;

@RequestMapping("/public")
@Controller
public class MajorController extends BaseController {
    @Autowired
    private MajorService majorService;
    @GetMapping("/getMajorsList")
    @ResponseBody
    public Result getMajorsList() {
        Result result;
        List<Major> majors = majorService.selectAll();
        if (majors != null) {
            result = Results.successWithData(majors, BaseEnums.SUCCESS.code(), BaseEnums.SUCCESS.desc());
            return result;
        }
        result = Results.failure(BaseEnums.FAILURE.code(), BaseEnums.FAILURE.desc());
        return result;
    }
}
